package com.ikingtech.framework.sdk.user.api;

import com.ikingtech.framework.sdk.base.model.BatchParam;
import com.ikingtech.framework.sdk.core.response.R;
import com.ikingtech.framework.sdk.user.model.*;
import com.ikingtech.framework.sdk.web.annotation.PostRequest;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * @author tie yan
 */
public interface UserApi {

    @PostRequest(order = 1, value = "/add", summary = "新增", description = "新增，新增成功后返回编号。")
    R<String> add(@Parameter(name = "user", description = "用户信息")
                  @RequestBody UserDTO user);

    @PostRequest(order = 2, value = "/delete", summary = "删除", description = "删除。")
    R<Object> delete(@Parameter(name = "id", description = "编号")
                     @RequestBody String id);

    @PostRequest(order = 3, value = "/update", summary = "更新", description = "更新。")
    R<Object> update(@Parameter(name = "user", description = "用户信息")
                     @RequestBody UserDTO user);

    @PostRequest(order = 3, value = "/info/update", summary = "更新用户基本信息", description = "更新用户基本信息。")
    R<Object> updateUserInfo(@Parameter(name = "user", description = "用户基本信息")
                             @RequestBody UserBasicDTO user);

    @PostRequest(order = 4, value = "/info/list/all", summary = "全量查询", description = "全量查询，没有查询结果时返回空列表。")
    R<List<UserBasicDTO>> allInfo();

    @PostRequest(order = 4, value = "/list/page", summary = "分页查询", description = "分页查询，没有查询结果时返回空列表。")
    R<List<UserDTO>> page(@Parameter(name = "queryParam", description = "查询条件")
                          @RequestBody UserQueryParamDTO queryParam);

    @PostRequest(order = 5, value = "/detail/id", summary = "查询详情", description = "查询详情，数据不存在时仍然返回成功,数据为null。")
    R<UserDTO> detail(@Parameter(name = "id", description = "编号")
                      @RequestBody String id);

    @PostRequest(order = 6, value = "/bind/social", summary = "绑定第三方平台", description = "绑定第三方平台标识信息")
    R<Object> bindSocial(@Parameter(name = "userBind", description = "用户绑定信息")
                         @RequestBody UserSocialBindDTO userBind);

    @PostRequest(order = 7, value = "/password/reset", summary = "重置密码(用户编号)", description = "重置密码，将指定用户的密码重置为初始密码，平台默认的用户初始密码为Abc123++。")
    R<Object> resetPassword(@Parameter(name = "id", description = "用户编号。")
                            @RequestBody String id);

    @PostRequest(order = 8, value = "/tenant/admin-user/password/reset", summary = "重置租户管理员密码(用户名)", description = "重置租户管理员密码，将指定用户的密码重置为初始密码，平台默认的用户初始密码为Abc123++。")
    R<Object> resetTenantAdminUserPassword(@Parameter(name = "tenantCode", description = "租户标识。")
                                           @RequestBody String tenantCode);

    @PostRequest(order = 9, value = "/password/modify", summary = "修改密码", description = "修改密码，修改指定用户的密码，需同时指定用户原密码和新密码，系统会校验原密码是否正确，正确时才会修改为新密码。")
    R<Object> modifyPassword(@Parameter(name = "modifyParam", description = "用户修改密码信息")
                             @RequestBody UserPasswordModifyParamDTO modifyParam);

    @PostRequest(order = 10, value = "/lock", summary = "锁定用户(用户名)", description = "锁定用户，调用此接口锁定用户后，用户变为永久锁定状态，必须由管理员或具有用户管理权限角色的其他用户手动解锁。")
    R<Object> lock(@Parameter(name = "username", description = "用户名")
                   @RequestBody String username);

    @PostRequest(order = 11, value = "/unlock", summary = "解锁用户(用户名)", description = "解锁用户，此接口在用户被手动锁定或因多次登录失败被锁定后调用。")
    R<Object> unlock(@Parameter(name = "username", description = "用户名")
                     @RequestBody String username);

    @PostRequest(order = 16, value = "/info/list/role-ids", summary = "查询用户(多角色编号)", description = "查询用户(多角色编号)，仅包含用户基本信息，不包含用户角色/部门/岗位信息，没有查询结果时返回空列表。")
    R<List<UserBasicDTO>> listInfoByRoleIds(@Parameter(name = "roleIds", description = "角色编号集合")
                                            @RequestBody BatchParam<String> roleIds);

    @PostRequest(order = 18, value = "/list/role-ids", summary = "查询用户(多角色编号)", description = "查询用户(多角色编号)，包含用户角色/部门/岗位信息，没有查询结果时返回空列表。")
    R<List<UserDTO>> listByRoleIds(@Parameter(name = "roleIds", description = "角色编号集合")
                                   @RequestBody BatchParam<String> roleIds);

    @PostRequest(order = 20, value = "/id/list/role-id", summary = "查询用户编号", description = "查询用户编号(角色编号)，没有查询结果时返回空字符串。")
    R<List<String>> listIdByRoleId(@Parameter(name = "roleId", description = "角色编号")
                                   @RequestBody String roleId);

    @PostRequest(order = 21, value = "/info/list/dept-ids", summary = "查询基本信息列表(部门编号)", description = "查询基本信息列表(部门编号)，仅包含用户基本信息，不包含用户角色/部门/岗位信息，没有查询结果时返回空列表。")
    R<List<UserBasicDTO>> listInfoByDeptIds(@Parameter(name = "deptIds", description = "部门编号集合")
                                            @RequestBody BatchParam<String> deptIds);

    @PostRequest(order = 21, value = "/info/list/org-ids", summary = "查询基本信息列表(组织编号)", description = "查询基本信息列表(组织编号)，仅包含用户基本信息，不包含用户角色/部门/岗位信息，没有查询结果时返回空列表。")
    R<List<UserBasicDTO>> listInfoByOrgIds(@Parameter(name = "orgIds", description = "组织编号集合")
                                           @RequestBody BatchParam<String> orgIds);

    @PostRequest(order = 21, value = "/list/org-ids", summary = "查询基本信息列表(组织编号)", description = "查询基本信息列表(组织编号)，仅包含用户基本信息，不包含用户角色/部门/岗位信息，没有查询结果时返回空列表。")
    R<List<UserDTO>> listByOrgIds(@Parameter(name = "orgIds", description = "组织编号集合")
                                  @RequestBody BatchParam<String> orgIds);

    @PostRequest(order = 22, value = "/id/list/dept-id", summary = "查询用户编号(单部门编号)", description = "查询用户编号(单部门编号)，没有查询结果时返回空列表。")
    R<List<String>> listIdByDeptId(@Parameter(name = "deptId", description = "部门编号")
                                   @RequestBody String deptId);

    @PostRequest(order = 22, value = "/id/list/dept-ids", summary = "查询用户编号(多部门编号)", description = "查询用户编号(多部门编号)，没有查询结果时返回空列表。")
    R<List<String>> listIdByDeptIds(BatchParam<String> deptIds);

    @PostRequest(order = 24, value = "/info/list/post-ids", summary = "查询用户(多岗位编号)", description = "查询用户(多岗位编号)，仅包含用户基本信息，不包含用户角色/部门/岗位信息，没有查询结果时返回空列表。")
    R<List<UserBasicDTO>> listInfoByPostIds(@Parameter(name = "postIds", description = "岗位编号集合")
                                            @RequestBody BatchParam<String> postIds);

    @PostRequest(order = 25, value = "/id/list/post-id", summary = "查询用户编号(单岗位编号)", description = "查询用户编号(单岗位编号)，没有查询结果时返回空列表。")
    R<List<String>> listIdByPostId(@Parameter(name = "postId", description = "岗位编号")
                                   @RequestBody String postId);

    @PostRequest(order = 27, value = "/info/list/menu-codes", summary = "查询用户(多菜单标识)", description = "查询用户(多菜单标识)，仅包含用户基本信息，不包含用户角色/部门/岗位信息，没有查询结果时返回空列表。")
    R<List<UserBasicDTO>> listInfoByMenuCodes(@Parameter(name = "menuCodes", description = "菜单标识集合。")
                                              @RequestBody BatchParam<String> menuCodes);

    @PostRequest(order = 28, value = "/info/list/menu-id", summary = "查询用户(菜单编号)", description = "查询用户(菜单编号)，仅包含用户基本信息，不包含用户角色/部门/岗位信息，没有查询结果时返回空列表。")
    R<List<UserBasicDTO>> listInfoByMenuId(@Parameter(name = "menuId", description = "菜单编号。")
                                           @RequestBody String menuId);

    @PostRequest(order = 30, value = "/info/list/ids", summary = "查询用户(多用户编号)", description = "查询用户(多用户编号)，仅包含用户基本信息，不包含用户角色/部门/岗位信息，没有查询结果时返回空列表。")
    R<List<UserBasicDTO>> listInfoByIds(@Parameter(name = "ids", description = "用户编号集合")
                                        @RequestBody BatchParam<String> ids);

    @PostRequest(order = 31, value = "/info/map/ids", summary = "查询用户Map(多用户编号)", description = "查询用户Map(多用户编号)，仅包含用户基本信息，不包含用户角色/部门/岗位信息，没有查询结果时返回空Map。")
    R<Map<String, UserBasicDTO>> mapInfoByIds(@Parameter(name = "ids", description = "用户编号集合")
                                              @RequestBody BatchParam<String> ids);

    @PostRequest(order = 32, value = "/list/ids", summary = "查询用户(多用户编号)", description = "查询用户(多用户编号)。")
    R<List<UserDTO>> listByIds(BatchParam<String> ids);

    @PostRequest(order = 34, value = "/info/id", summary = "查询基本信息(用户编号)", description = "查询用户(用户编号)，数据不存在时仍然返回成功,数据为null。")
    R<UserBasicDTO> getInfoById(@Parameter(name = "id", description = "用户编号")
                                @RequestBody String id);

    @PostRequest(order = 35, value = "/credential", summary = "查询基本信息(用户身份凭证)", description = "查询基本信息(用户身份凭证)，数据不存在时仍然返回成功,数据为null。")
    R<UserBasicDTO> getInfoByCredential(@Parameter(name = "credentialName", description = "用户身份凭证")
                                        @RequestBody String credentialName);

    @PostRequest(order = 35, value = "/info/social", summary = "查询基本信息(用户社交号)", description = "查询基本信息(用户社交号)，数据不存在时仍然返回成功,数据为null。")
    R<UserBasicDTO> getInfoBySocial(@Parameter(name = "queryParam", description = "查询参数")
                                    @RequestBody UserSocialQueryParamDTO queryParam);

    @PostRequest(order = 37, value = "/info/login-user", summary = "查询基本信息(登录用户)", description = "查询基本信息(登录用户)，指定的用户不存在时仍然返回成功,数据为null。")
    R<UserBasicDTO> getLoginUser();

    @PostRequest(order = 38, value = "/config/update", summary = "新增或更新配置", description = "新增或更新配置。")
    R<Object> updateConfig(@Parameter(name = "userConfigDTO", description = "主题信息")
                           @RequestBody UserConfigDTO userConfigDTO);

    @PostRequest(order = 39, value = "/configs/list/login-user", summary = "查询配置(登录用户)", description = "查询配置(登录用户)，没有查询结果时返回空列表。")
    R<UserConfigDTO> listConfigByLoginUser(@RequestParam(value = "global", required = false) Boolean global);

    @PostRequest(order = 39, value = "/front-gray-scale/value", summary = "获取页面灰度值", description = "获取页面灰度值。")
    R<String> getFrontGrayScale(@RequestParam(value = "global", required = false) Boolean global);

    @PostRequest(order = 41, value = "/recent/tenant/login-user", summary = "记录用户登录时所选租户标识", description = "保存用户最近一次登录时选择的租户信息")
    R<Object> getRecentTenantByLoginUser();

    @PostRequest(order = 41, value = "/recent/tenant/remember", summary = "记录用户登录时所选租户标识", description = "保存用户最近一次登录时选择的租户信息")
    R<Object> rememberUserLoginTenant(@Parameter(name = "tenantCode", description = "用户最近一次登录的租户信息")
                                      @RequestBody String tenantCode);

    @PostRequest(order = 39, value = "/category/list/login-user", summary = "查询身份列表", description = "查询身份列表，没有查询结果时返回空列表。")
    R<List<UserCategoryDTO>> listCategoryByLoginUser();

    @PostMapping(value = "/id/list/name")
    R<List<String>> listIdByName(String name);
}
